import React, { useEffect, useState } from 'react'
import moment from 'moment'

export default function Son() {
  let [nowData, setNowData] = useState(moment().format('YYYY-MM-DD HH:mm:ss'))
  useEffect(() => {
    let timer = setInterval(()=> {
        console.log('setInerval');
        
        setNowData(moment().format('YYYY-MM-DD HH:mm:ss'))
    },1000)
    return ()=> {
        clearInterval(timer)
        console.log('定时器结束');
        
    }
  })
  return (
    <div>
      <h3>当前时间：{nowData}</h3>
    </div>
  )
}
